package com.spark.lola.configuration;


import com.spark.lola.feign.service.PortalServiceOpenApi;
import com.spark.lola.support.configuration.OssProperties;
import com.spark.lola.support.mvc.service.ExcelServiceImpl;
import com.spark.lola.support.warehouse.configuration.FztApiProperties;
import com.spark.lola.support.wms.configuration.JPushProperties;
import com.spark.lola.support.wms.job.WmsJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.transaction.PlatformTransactionManager;

import javax.annotation.PostConstruct;
import javax.sql.DataSource;

/**
 * 当前项目 Bean注入
 *
 * @Author: DengYeJun
 * @Date: 2020/4/22 11:28
 */
@Configuration
@EnableConfigurationProperties({FztApiProperties.class, JPushProperties.class})
public class WarehouseConfiguration {
    private Logger logger = LoggerFactory.getLogger(getClass());

//    @Bean
//    public PlatformTransactionManager transactionManager(DataSource dynamicDataSource)
//    {
//        return new DataSourceTransactionManager(dynamicDataSource);
//    }

    @Bean
    public BCryptPasswordEncoder bCryptPasswordEncoder() {
        return new BCryptPasswordEncoder(10);
    }

    /**
     * 启动任务
     */
    @PostConstruct
    public void init() {

    }

    @Bean
    public WmsJob wmsJob(PortalServiceOpenApi portalServiceOpenApi) {
        return new WmsJob(portalServiceOpenApi);
    }

    /**
     * excel组件服务注入
     * @return
     */
    @Bean
    public ExcelServiceImpl excelService(OssProperties ossProperties) {
        return new ExcelServiceImpl(ossProperties);
    }

}
